/**
 * 
 */
package idv.takeshi.software.productline.bookstore.application.service.dto;

import idv.takeshi.software.productline.bookstore.domain.model.order.Atm;
import idv.takeshi.software.productline.bookstore.domain.model.order.Order;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * A DTO for maintaining ATM payment operations.
 * @author takeshi
 *
 */
public class AtmPaymentDto extends PaymentDto {
	
	@Pattern(regexp = "\\d{3,3}+")
	@NotNull
	private String transferBankId;
	
	
	@Pattern(regexp = "\\d{16,16}+")
	@NotNull
	private String transferAccountNumber;
	
	@Pattern(regexp = "\\d{3,3}+")
	@NotNull
	private String depositBankId;
	
	
	@Pattern(regexp = "\\d{16,16}+")
	@NotNull
	private String depositAccountNumber;

	/**
	 * Default constructor. 
	 */
	public AtmPaymentDto() {
		super();
	}
	
	/**
	 * Initial this DTO by given ATM model.
	 * @param atm 
	 */
	public AtmPaymentDto(Order order) {
		super(order);
		Atm atm = (Atm) order.getPayment();
		this.transferBankId = atm.getTransferBankId();
		this.transferAccountNumber = atm.getTransferAccountNumber();
		this.depositBankId = atm.getDepositForBankId();
		this.depositAccountNumber = atm.getDepositForAccountNumber();
	}

	/**
	 * @return the transferBankId
	 */
	public String getTransferBankId() {
		return transferBankId;
	}

	/**
	 * @param transferBankId the transferBankId to set
	 */
	public void setTransferBankId(String transferBankId) {
		this.transferBankId = transferBankId;
	}

	/**
	 * @return the transferAccountNo
	 */
	public String getTransferAccountNumber() {
		return transferAccountNumber;
	}

	/**
	 * @param transferAccountNumber the transferAccountNo to set
	 */
	public void setTransferAccountNumber(String transferAccountNumber) {
		this.transferAccountNumber = transferAccountNumber;
	}

	/**
	 * @return the depositBankId
	 */
	public String getDepositBankId() {
		return depositBankId;
	}

	/**
	 * @param depositBankId the depositBankId to set
	 */
	public void setDepositBankId(String depositBankId) {
		this.depositBankId = depositBankId;
	}

	/**
	 * @return the depositAccountNo
	 */
	public String getDepositAccountNumber() {
		return depositAccountNumber;
	}

	/**
	 * @param depositAccountNumber the depositAccountNo to set
	 */
	public void setDepositAccountNumber(String depositAccountNumber) {
		this.depositAccountNumber = depositAccountNumber;
	}
	
	/* (non-Javadoc)
	 * @see idv.takeshi.software.productline.bookstore.application.service.dto.PaymentDto#loadModel(idv.takeshi.software.productline.bookstore.domain.model.order.Order)
	 */
	public void loadModel(Order order){
		super.loadModel(order);
		
		Atm atm = (Atm) order.getPayment();
		atm.setTransferBankId(transferBankId);
		atm.setTransferAccountNumber(transferAccountNumber);
		atm.setDepositForBankId(depositBankId);
		atm.setDepositForAccountNumber(depositAccountNumber);
	}
	
	
}
